<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>setctrl</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="seqtime.html" title="seqtime" />
    <link rel="next" href="setksmps.html" title="setksmps" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">setctrl</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="seqtime.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="setksmps.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="setctrl"></a>
      <div class="titlepage"></div>
      <a id="IndexSetctrl" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">setctrl</span>
        </h2>
        <p>setctrl — 
      Configurable slider controls for realtime user input.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp145621920"></a>
        <h2>Description</h2>
        <p>
      Configurable slider controls for realtime user input. Requires Winsound or TCL/TK. <span class="emphasis"><em>setctrl</em></span> sets a slider to a specific value, or sets a minimum or maximum range.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145623840"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>setctrl</strong></span> inum, ival, itype</pre>
      </div>
      <div class="refsect1">
        <a id="idp145625920"></a>
        <h2>Initialization</h2>
        <p>
      Note that this opcode is not available on Windows due to the implimentation of pipes on that system 
    </p>
        <p>
      <span class="emphasis"><em>inum</em></span> -- number of the slider to set
    </p>
        <p>
      <span class="emphasis"><em>ival</em></span> -- value to be sent to the slider
    </p>
        <p>
      <span class="emphasis"><em>itype</em></span> -- type of value sent to the slider as follows:
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">
              <p>1 -- set the current value. Initial value is 0.</p>
            </li>
            <li class="listitem">
              <p>2 -- set the minimum value. Default is 0.</p>
            </li>
            <li class="listitem">
              <p>3 -- set the maximum value. Default is 127.</p>
            </li>
            <li class="listitem">
              <p>4 -- set the label. (New in Csound version 4.09)</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145632784"></a>
        <h2>Performance</h2>
        <p>
      Calling <span class="emphasis"><em>setctrl</em></span> will create a new slider on the screen. There is no theoretical limit to the number of sliders. Windows and TCL/TK use only integers for slider values, so the values may need rescaling. GUIs usually pass values at a fairly slow rate, so it may be advisable to pass the output of control through <span class="emphasis"><em>port</em></span>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145635216"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the setctrl opcode. It uses the file <a class="ulink" href="examples/setctrl.csd" target="_top"><em class="citetitle">setctrl.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp145637072"></a>
          <p class="title">
            <strong>Example 801. Example of the setctrl opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o setctrl.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Initialize the global variables.</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 1

<span class="comment">; Instrument #1.</span>
<span class="oblock">instr</span> 1
  <span class="comment">; Display the label "Volume" on Slider #1.</span>
  setctrl 1, "Volume", 4
  <span class="comment">; Set Slider #1's initial value to 20.</span>
  setctrl 1, 20, 1
  
  <span class="comment">; Capture and display the values for Slider #1.</span>
  k1 control 1
  <span class="opc">printk2</span> k1

  <span class="comment">; Play a simple oscillator.</span>
  <span class="comment">; Use the values from Slider #1 for amplitude.</span>
  kamp <span class="op">=</span> k1 <span class="op">*</span> 128
  a1 <span class="opc">oscil</span> kamp, 440, 1
  <span class="opc">out</span> a1
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Table #1, a sine wave.</span>
<span class="stamnt">f</span> 1 0 16384 10 1

<span class="comment">; Play Instrument #1 for thirty seconds.</span>
<span class="stamnt">i</span> 1 0 30
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />

      Its output should include lines like this:
      </p>
        <pre class="screen">
 i1    38.00000
 i1    40.00000
 i1    43.00000
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145642176"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="control.html" title="control"><em class="citetitle">control</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp145644320"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: John ffitch</td>
          </tr>
          <tr>
            <td>University of Bath, Codemist. Ltd.</td>
          </tr>
          <tr>
            <td>Bath, UK</td>
          </tr>
          <tr>
            <td>May 2000</td>
          </tr>
        </table>
        <p>
    </p>
        <p>Example written by Kevin Conder.</p>
        <p>New in Csound version 4.06</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="seqtime.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="setksmps.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">seqtime </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> setksmps</td>
        </tr>
      </table>
    </div>
  </body>
</html>
